package com.lry;

import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

@Slf4j
public class RedPacket {

    BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();

    public void sendPacket(int money,int person){
        List<Integer> cal = RedUtil.cal(money, person);
        for (Integer integer : cal) {
            queue.add(integer);
        }
    }

    public void robPacket(){
        if(queue.isEmpty()){
            log.info("红包已领取完毕");
            return;
        }

        Integer money = queue.poll();
        if(null!=money){
            log.info("抢到了{}",money);
        }else{
            log.info("没抢到");
        }
    }
}
